<template>
    <el-main>
        <el-main class="ep-body">
            <epl-top-bar :datas="{formData:form}" showPerson personType="PERSON_ALL_EXACT" psTagType="PERSON_PENSION_QUERY">
                <ep-button size="small" name="打印"></ep-button>
                <ep-button size="small" name="刷新"></ep-button>
            </epl-top-bar>
            <epl-userMessage dataType="person" idCount="8">
            </epl-userMessage>
            <el-card class="ep-card">
                <ep-title>请输入精减人员发放信息</ep-title>
                <el-form :model="form" ref="form" :rules="rules">
                    <el-row :gutter="20">
                        <ep-select colspan="8" label="新发放银行" name="aaz065" :property="form.aaz065" placeholder="请选择新发放银行"
                                   p="R" :datas="{formData: form}" codetype="AAZ065" rules="this.$rules.test_noBlank"></ep-select>
                        <ep-input  colspan="8" label="新银行账号" name="aae010" :property="form.aae010" placeholder="请输入新银行账号"
                                   p="R" :datas="{formData: form }" rules="this.$rules.test_noBlank"></ep-input >
                        <ep-input  colspan="8" label="新银行开户名" name="aae009" :property="form.aae009" placeholder="请输入新银行开户名"
                                   p="R" :datas="{formData: form }" rules="this.$rules.test_noBlank"></ep-input >
                    </el-row>
                    <el-row :gutter="20">
                        <epl-search-bank colspan="8" label="新开户行行号" name="aaf002" :property="form.aaf002" placeholder="请选择新开户行行号"
                                         p="R" :datas="{formData: form}" codetype="AAZ065" bankName="aaz065" show rules="this.$rules.test_noBlank"></epl-search-bank>
                        <ep-input  colspan="16" label="新开户银行名称" name="bac049" :property="form.bac049"
                                   p="R,D" :datas="{formData: form }" rules="this.$rules.test_noBlank"></ep-input >
                    </el-row>
                    <el-row :gutter="20">
                        <ep-select colspan="8" label="原发放银行" name="aaz065_old" :property="form.aaz065_old"
                                   p="D" :datas="{formData: form}" codetype="AAZ065" ></ep-select>
                        <ep-input  colspan="8" label="原银行账号" name="aae010_old" :property="form.aae010_old"
                                   p="D" :datas="{formData: form }" ></ep-input >
                        <ep-input  colspan="8" label="原银行开户名" name="aae009_old" :property="form.aae009_old"
                                   p="D" :datas="{formData: form }" ></ep-input >
                    </el-row>
                    <el-row :gutter="20">
                        <ep-input colspan="8" label="原开户行行号" name="aaf002_old" :property="form.aaf002_old"
                                  p="D" :datas="{formData: form}" ></ep-input>
                        <ep-input  colspan="16" label="原开户银行名称" name="bac049_old" :property="form.bac049_old"
                                   p="D" :datas="{formData: form }" ></ep-input >
                    </el-row>
                    <el-row :gutter="20">
                        <ep-date colspan="8" label="变更日期" name="aae035" :property="form.aae035" placeholder="请选择变更日期"
                                 p="R,D" :datas="{formData: form }" type="date" format="yyyy-MM-dd" value-format="yyyyMMdd"></ep-date>
                    </el-row>
                    <el-row>
                        <ep-textarea :rows="3" label="备注" name="aae013" :property="form.aae013" placeholder="请输入备注信息"
                                     p="E" :datas="{formData: form}"></ep-textarea>
                    </el-row>
                    <el-row type="flex" justify="center">
                        <ep-saveButton id="doSave" type="primary" top="20"  bottom="20" ref="save" @formValidate="formValidate" :validate="['form']"
                                       :datas="{formData: form,panel:panel}" name="保存"></ep-saveButton>
                    </el-row>
                </el-form>
            </el-card>
        </el-main>
    </el-main>
</template>
<script type="es6">
    export default {
        data() {
            return {
                form:{
                    aaz065: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae010: {
                        value: '',
                        p: 'R'
                    },
                    aae009: {
                        value: '',
                        p: 'R'
                    },
                    aaf002: {
                        value: '',
                        p: 'R'
                    },
                    bac049: {
                        value: '',
                        p: 'R,D'
                    },
                    aaz065_old: {
                        key: '',
                        value: '',
                        p: 'D'
                    },
                    aae010_old: {
                        value: '',
                        p: 'D'
                    },
                    aae009_old: {
                        value: '',
                        p: 'D'
                    },
                    aaf002_old: {
                        value: '',
                        p: 'D'
                    },
                    bac049_old: {
                        value: '',
                        p: 'D'
                    },
                    aae035: {
                        value: '',
                        p: 'R,D'
                    },
                    aae013: {
                        value: '',
                        p: 'E'
                    },

                },
                panel: {},

                rules:{
                    aaz065: [
                        {required: true, validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae010: [
                        {required: true, validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae009: [
                        {required: true, validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aaf002: [
                        {required: true, validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    bac049: [
                        {required: true, validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae035: [
                        {required: true, message: '必填项，不能为空'}

                    ],

                },
                codeTypes:{
                    AAZ065:[],

                },
                codeTypeFilters:{

                },
                pager: {
                    page: 1,
                    size: 10
                },
                total: 0,
            }
        },
        computed: {
            functionId() {
                if (this.$store.getters.init.path !== this.$route.path) return;
                if (this.$store.getters.init.mdParam === null || this.$store.getters.init.mdParam === undefined) return;
                if (this.$store.getters.init.mdParam.functionid === undefined) return;
                return this.$store.getters.init.mdParam.functionid;
            },
            backFun() {
                return this.$store.getters.backFun;
            },
            init_formData() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.form;
            },
            doInitformData: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.formData;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },
            init_panel() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.panel;
            },
            doInitpanel: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.panel;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },

        },
        created() {
            let param = {
                path: this.$route.path,
                codeTypes:this.codeTypes,
                codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                form:this.form,
                panel:this.panel

            };
            this.$store.dispatch('SET_INIT', param);
        },
        watch: {
            init_formData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            doInitformData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            init_panel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },
            doInitpanel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },

            backFun: {
                handler(value) {
                    if (value === null) return;
                    this.customBackFun();
                    let backFun = [];
                    backFun = value.split(',');
                    if (backFun.indexOf('rDoInit') >= 0) {
                        let codeTypes = {
                            AAZ065:[],

                        };
                        let form = {
                            aaz065: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae010: {
                                value: '',
                                p: 'R'
                            },
                            aae009: {
                                value: '',
                                p: 'R'
                            },
                            aaf002: {
                                value: '',
                                p: 'R'
                            },
                            bac049: {
                                value: '',
                                p: 'R,D'
                            },
                            aaz065_old: {
                                key: '',
                                value: '',
                                p: 'D'
                            },
                            aae010_old: {
                                value: '',
                                p: 'D'
                            },
                            aae009_old: {
                                value: '',
                                p: 'D'
                            },
                            aaf002_old: {
                                value: '',
                                p: 'D'
                            },
                            bac049_old: {
                                value: '',
                                p: 'D'
                            },
                            aae035: {
                                value: '',
                                p: 'R,D'
                            },
                            aae013: {
                                value: '',
                                p: 'E'
                            },

                        };
                        let panel= {};

                        let param = {
                            path: this.$route.path,
                            codeTypes:codeTypes,
                            codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                            form:form,
                            panel:panel

                        };
                        this.$store.dispatch('SET_INIT', param);
                    }
                }
            }
        },
        methods: {
            getformData(value) {
                this.form = value;
            },
            getpanel(value) {
                this.panel = value;
            },

            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            handleEdit(id) {
                this.dialogFormVisible = true;
            },
            formValidate(value){
                if(value && value.length>0){
                    value.map((item,index)=>{
                        this.$refs[item].validate((valid) => {
                            if (valid) {
                                if(index+1 == value.length){
                                    this.$refs.save.btn();
                                }
                            } else {
                                return false;
                            }
                        });
                    })
                }
            },

            customBackFun(){//自定义方法体
            },
        },
    }
</script>
